package com.esproject.Controller;

import com.alibaba.fastjson.JSON;

import java.util.Map;

/**
 * Created by yan_li on 2017/2/25.
 */
public class BaseAction {
    protected static final String SuccessResult = "{\"code\":10000,\"message\":\"ok\"}";
    protected static final String ErrorResult = "{\"code\":10500,\"message\":\"error\"}";
    protected static final String NOLOGIN = "{\"code\":10501,\"message\":\"error\"}";
    protected static final String NOAccess = "{\"code\":10606,\"message\":\"error\"}";
    protected static String getSuccessResult(Map<String, Object> respData) {
        respData.put("code", 10000);
        respData.put("message", "ok");
        return JSON.toJSONString(respData);
    }

    protected static <V> String getSuccessResult(String paramName, V paramValue) {
        Map parseObject = JSON.parseObject(SuccessResult, Map.class);
        parseObject.put(paramName, paramValue);
        return JSON.toJSONString(parseObject);
    }
}
